package com.hex.ds.hdrs.common.exception;

import com.hex.ds.hdrs.common.constant.ErrorCode;
import lombok.Data;

/**
 * @Package: com.hex.ds.hdrs.common.exception
 * @ClassName BizException
 * @Description: 业务异常
 * @Author: jd.chen
 * @Date 2021/7/12 11:03
 * @Version v1.0
 **/
@Data
public class BizException extends RuntimeException {
    private String code;
    private String errMsg;

    public BizException(String code, String errMsg, Exception e) {
        super(code, e);
        this.code = code;
        this.errMsg = errMsg;
    }

    public BizException(String code, String errMsg) {
        this.code = code;
        this.errMsg = errMsg;
    }

    public BizException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.errMsg = errorCode.getMessage();
    }

    public BizException(ErrorCode errorCode, String errMsg) {
        this.code = errorCode.getCode();
        this.errMsg = errMsg;
    }

    public BizException(ErrorCode errorCode, Exception e) {
        super(errorCode.getCode(), e);
        this.code = errorCode.getCode();
        this.errMsg = errorCode.getMessage();
    }

    public BizException(ErrorCode errorCode, Exception e, String errMsg) {
        super(errorCode.getCode(), e);
        this.code = errorCode.getCode();
        this.errMsg = errMsg;
    }
}
